// Copyright (c) MatrixFramework. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MatrixFramework.Core.Results;
using MatrixFramework.Photos.Domain.Entities;
using MatrixFramework.Photos.Domain.Shared.Enums;

namespace MatrixFramework.Photos.Domain.Services;

/// <summary>
/// 照片搜索服务接口
/// </summary>
public interface IPhotoSearchService
{
    /// <summary>
    /// 根据标签搜索照片
    /// </summary>
    /// <param name="tags">标签列表</param>
    /// <param name="tenantId">租户ID</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>搜索结果</returns>
    Task<Result<IReadOnlyList<Photo>>> SearchByTagsAsync(
        IEnumerable<string> tags,
        Guid? tenantId = null,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 根据日期范围搜索照片
    /// </summary>
    /// <param name="startDate">开始日期</param>
    /// <param name="endDate">结束日期</param>
    /// <param name="tenantId">租户ID</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>搜索结果</returns>
    Task<Result<IReadOnlyList<Photo>>> SearchByDateRangeAsync(
        DateTime startDate,
        DateTime endDate,
        Guid? tenantId = null,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 根据人物搜索照片
    /// </summary>
    /// <param name="personNames">人物姓名列表</param>
    /// <param name="tenantId">租户ID</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>搜索结果</returns>
    Task<Result<IReadOnlyList<Photo>>> SearchByPeopleAsync(
        IEnumerable<string> personNames,
        Guid? tenantId = null,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 根据地理位置搜索照片
    /// </summary>
    /// <param name="latitude">纬度</param>
    /// <param name="longitude">经度</param>
    /// <param name="radius">搜索半径（米）</param>
    /// <param name="tenantId">租户ID</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>搜索结果</returns>
    Task<Result<IReadOnlyList<Photo>>> SearchByLocationAsync(
        double latitude,
        double longitude,
        double radius = 1000,
        Guid? tenantId = null,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 根据处理状态搜索照片
    /// </summary>
    /// <param name="status">处理状态</param>
    /// <param name="tenantId">租户ID</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>搜索结果</returns>
    Task<Result<IReadOnlyList<Photo>>> SearchByStatusAsync(
        PhotoProcessingStatus status,
        Guid? tenantId = null,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 根据照片类型搜索照片
    /// </summary>
    /// <param name="photoType">照片类型</param>
    /// <param name="tenantId">租户ID</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>搜索结果</returns>
    Task<Result<IReadOnlyList<Photo>>> SearchByTypeAsync(
        PhotoType photoType,
        Guid? tenantId = null,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 全文搜索照片
    /// </summary>
    /// <param name="keyword">关键词</param>
    /// <param name="tenantId">租户ID</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>搜索结果</returns>
    Task<Result<IReadOnlyList<Photo>>> FullTextSearchAsync(
        string keyword,
        Guid? tenantId = null,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 相似度搜索照片
    /// </summary>
    /// <param name="referencePhotoId">参考照片ID</param>
    /// <param name="similarityThreshold">相似度阈值</param>
    /// <param name="tenantId">租户ID</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>搜索结果</returns>
    Task<Result<IReadOnlyList<Photo>>> SearchBySimilarityAsync(
        Guid referencePhotoId,
        double similarityThreshold = 0.8,
        Guid? tenantId = null,
        CancellationToken cancellationToken = default);
}